<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>splice()</title>
	</head>
	<body>
		<p id="old">原始数组</p>
		<p id="mynew">修改之后的数组</p>
		<botton onclick="my()">点击</botton>
		<script>
			function my(){
				//获取p标签元素对象
				var old=document.getElementById('old');
				var mynew=document.getElementById('mynew');
				//定义数组
				var fruits=["Banana","Orange","Apple","Mango"];
				old.innerHTML=fruits;
				
				//在Orange元素之后，添加元素，pear、peach
				//  fruits.splice(2,0,"pear","peach");
				//  mynew.innerHTML=fruits;
				
				//在Orange元素之后，删除2个元素
				fruits.splice(0,2);
				mynew.innerHTML=fruits;
			}
		</script>
	</body>
</html>
